package com.systop.domain.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;

import java.math.BigDecimal;
import java.util.Map;

/**
 * @Description: 购物项内容
 * @Author: jsj
 * @Date: 2023/3/11
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CartItem implements Comparable<CartItem>{

    private Long goodsId;
    private String goodsName;
    private String goodsImg;
    private Integer stockNum;

    private Boolean isCheck = true;

    private BigDecimal price;
    private Integer count;
    private BigDecimal totalPrice;

    //总价计算
    public BigDecimal getTotalPrice() {
        return this.price.multiply(new BigDecimal(""+this.count));
    }

    @Override
    public int compareTo(CartItem item) {
        return (int) (item.getGoodsId() - this.goodsId);
    }
}
